<template>
	<view :style="'background: url('+ c_imgPath + 'chouka/indexBg.png'+ ') repeat-y 0 0 / 100% auto;'">
		<view class="box">
			<view class="title">
				<view class="title_item" v-for="(item,index) in tujian_cate" :key="index"
					@click="change_tujian(item.id)">
					<view class="title_text">
						<text :class="item.id == tujian_id?'selectTitle':''">{{item.title}}</text>
						<view class="title_text_rate" v-if="item.rate != -1">({{item.pro}})</view>
					</view>
					<view class="title_img" v-if="item.id == tujian_id">
						<image :src="c_imgPath + 'shouye/xzs_sel.png'"></image>
					</view>
				</view>
			</view>
		</view>
		<scroll-view scroll-y="true" @scrolltolower="getTujian" style="height: 95vh;">
			<view class="tuijian_list">
				<view class="tuijian_item" v-for="(item,index) in tujian_Arr" :key="index"
					:style="'background: url('+ c_imgPath + 'detail/item_bg.png'+ ') repeat-y 0 0 / 100% 100%;'">
					<image class="tuijian_item_img" mode="aspectFill" :src="item.imgurl"></image>
					<view class="tuijian_item_title hang1">{{item.title}}</view>
					<view class="tuijian_item_desc">参考价:￥{{item.price}}</view>
					<!-- <view class="tuijian_item_desc">{{item.real_pro}}</view> -->
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				c_imgPath: 'https://qt.yhemall.com/',
				cc_imgPath: '/static/',
				mixTotal_t: 0,
				page_num_t: 1,
				tujian_id: 0,
				goods_id: '',
				tujian_Arr: [],
				tujian_cate: [{
					title: '全部',
					id: 0,
					rate: -1
				}]
			}
		},
		onLoad(o) {
			this.goods_id = o.id;
			this.getClass();
			this.getTujian();
		},
		methods: {
			// 图鉴详情
			change_tujian(e) {
				this.tujian_id = e
				this.page_num_t = 1
				this.tujian_Arr = []
				this.getTujian()
			},
			getTujian() {
				let that = this;
				if (this.page_num_t !== 1 && this.page_num_t > this.mixTotal_t) {
					return
				}
				that.req({
					url: 'shang_goods',
					Loading: true,
					data: {
						page: that.page_num_t,
						card_id: that.goods_id,
						shang_id: that.tujian_id
					},
					success(res) {
						if (res.status == 1) {
							that.mixTotal_t = res.data.goods.last_page;
							if (that.page_num_t === 1) {
								that.tujian_Arr = res.data.goods.data;
							} else {
								that.tujian_Arr = that.tujian_Arr.concat(res.data.goods.data)
							}
							that.page_num_t += 1
						}
					}
				})
			},
			getClass() {
				let that = this;
				that.req({
					url: 'shang_goods',
					Loading: true,
					data: {
						page: that.page_num_t,
						card_id: that.goods_id,
						shang_id: that.tujian_id
					},
					success(res) {
						that.tujian_cate = that.tujian_cate.concat(res.data.card_level);
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.box {
		overflow: hidden;
		height: 72rpx;

		.title {
			width: 690rpx;
			margin: auto;
			display: flex;
			overflow-x: scroll;
			padding-bottom: 20rpx;

			.title_item {
				flex-shrink: 0;
				padding: 4rpx 20rpx;

				.title_text {
					font-size: 28rpx;
					font-family: Source Han Sans CN;
					font-weight: bold;
					color: #9E99E3;
					display: flex;
					align-items: center;
					justify-content: center;

					.selectTitle {
						font-size: 32rpx;
						background: linear-gradient(0deg, #B75AFF 0%, #E7CBFF 100%);
						-webkit-background-clip: text;
						-webkit-text-fill-color: transparent;
					}

					.title_text_rate {}
				}

				.title_img {
					text-align: center;

					image {
						width: 94rpx;
						height: 24rpx;
					}
				}
			}
		}
	}

	.tuijian_list {
		display: flex;
		align-items: center;
		// justify-content: space-between;
		flex-wrap: wrap;
		width: 690rpx;
		margin: auto;
		padding-bottom: env(safe-area-inset-bottom);

		/* height: 700rpx; */
		.tuijian_item {
			font-size: 24rpx;
			text-align: center;
			width: 202rpx;
			height: 433rpx;
			margin-top: 20rpx;
			color: #FFFFFF;
			padding: 5rpx;

			.tuijian_item_img {
				width: 100%;
				height: 290rpx;
			}

			.tuijian_item_title {
				font-size: 24rpx;
				font-family: Source Han Sans CN;
				font-weight: bold;
				background: linear-gradient(0deg, #A98FD3 0%, #FFFFFF 100%);
				-webkit-background-clip: text;
				-webkit-text-fill-color: transparent;
				margin-top: 12rpx;
			}

			.tuijian_item_desc {
				font-size: 20rpx;
				opacity: 0.6;
				margin-top: 12rpx;
			}
		}

		.tuijian_item:nth-child(3n+2) {
			margin: 30rpx 30rpx 0;
		}
	}
</style>